package com.icoo.base.model;

import lombok.Data;

@Data
public class ResultModel {

    private  String msg;

    private  int code;

    private  boolean state;

    public static ResultModel success(){
        return resultModel("操作成功！",200,true);
    }

    public static ResultModel success(String msg){
        return resultModel(msg,200,true);
    }

    public static ResultModel success(String msg, int code){
        return resultModel(msg,code,true);
    }

    public static ResultModel fail(){
        return resultModel("操作失败！",500,false);
    }

    public static ResultModel fail(String msg){
        return resultModel(msg,500,false);
    }

    public static ResultModel fail(String msg, int code){
        return resultModel(msg,code,false);
    }

    private static ResultModel resultModel(String msg, int code, boolean state) {
        ResultModel resultModel = new ResultModel();
        resultModel.setCode(code);
        resultModel.setMsg(msg);
        resultModel.setState(state);
        return resultModel;
    }
}
